package com.example.newgame;

import android.app.Activity;
import android.os.Bundle;


public class NewGameListActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
/*

        final ServerConnectorFacade connector = new ServerConnectorFacade();
        Document document = null;
        try {
            connector.loadGameList();
        } catch (UnknownHostException e) {
            // todo handle exception
            e.printStackTrace();
        }

        Parser parser = new Parser();
        List<NewGame> newGames = parser.loadGames(document);


        setContentView(R.layout.newgamelinelayout);
        final LinearLayout layout = (LinearLayout) findViewById(R.id.newGameLine);
        LayoutInflater linflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);


        for (final NewGame newGame : newGames) {

            View customNewGameLine = linflater.inflate(R.layout.newgameline, null);
            TextView name = (TextView) customNewGameLine.findViewById(R.id.newGameName);
            name.setText(newGame.getName());

            name.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {

                    String[] races = new String[newGame.getRaces().size()];
                    int index = 0;
                    for (NewGameRace newGameRace : newGame.getRaces()) {
                        races[index++] = newGameRace.getName();
                    }

                    Context context = layout.getContext();

                    Intent i = new Intent(context, NewGameDescriptionActivity.class);
                    i.putExtra("name", newGame.getName());
                    i.putExtra("races", races);
                    context.startActivity(i);
                }
            });

            layout.addView(customNewGameLine);

        }

*/
    }
}
